# 变量使用
var1=23
echo $var1

# $(date) 等价于 `date`
time1=$(date)
echo time1 is $time1

time2=`date`
echo time2 is $time2
echo time2 is ${time2}

testing=$(date +%y%m%d)
# ls /usr/bin -al > log.$testing

# 数学计算
varAdd=$(expr $var1 + 10)
echo $varAdd
varAdd=$[$var1 + 111]  # 推荐 只支持整数
echo $varAdd

var1=$(echo "scale=4; 3.44 / 5" | bc)
echo The answer is $var1

var2=$(bc << EOF
scale=4
a1=(2.3 * 2)
a2 = (2 * 6)
a1 + a2
EOF
)
echo The final answer is $var2

# 获取命令执行的退出状态
date
echo date 的执行状态是 $?
sdsd
echo "sdsd的执行状态是 $?"
# 退出脚本
exit 0